#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
#=============================================================================
#     FileName: model.py
#         Desc: models for pynhk
#      License: GPL
#       Author: Steve Lemuel
#        Email: wlemuel@hotmail.com
#      Version: 0.0.1
#   LastChange: 2015-09-07 14:42:07
#    CreatedAt: 2015-09-07 14:42:07
#=============================================================================
"""
import datetime

from sqlalchemy import Column, String, Integer, Date, DateTime
from sqlalchemy.ext.declarative import declarative_base

from config import (
    DB_TNEWS,
    DB_TCONFIGER,
    DB_TRESOURCE,
    DB_TSITES,
)

Base = declarative_base()


class News(Base):
    __tablename__ = DB_TNEWS

    id = Column(Integer, primary_key=True)
    news_id = Column(String(50), nullable=True, unique=True)
    title = Column(String(200), default='')
    file = Column(String(100), nullable=True)
    size = Column(Integer)
    duration = Column(String(20), nullable=True)
    link = Column(String(225))
    status = Column(Integer, default=0)

    def __repr__(self):
        return '<News(%s)>' % self.title


class Configer(Base):
    __tablename__ = DB_TCONFIGER

    id = Column(Integer, primary_key=True)
    key = Column(String(20))
    value = Column(String(100))


class TResource(Base):
    __tablename__ = DB_TRESOURCE

    id = Column(Integer, primary_key=True)
    site = Column(String(50))
    url = Column(String(512), unique=True, nullable=False)
    medium_type = Column(String(10))
    created = Column(DateTime, default=datetime.datetime.now)
    status = Column(Integer, default=0)


class TSite(Base):
    __tablename__ = DB_TSITES

    id = Column(Integer, primary_key=True)
    site = Column(String(50))
    status = Column(Integer, default=0)
    finished_at = Column(String(20))
